import Vue from 'vue'
import VueRouter from 'vue-router'
import About from '../views/About.vue'
import Home2 from '../views/Home2.vue'

const originalPush = VueRouter.prototype.push

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

Vue.use(VueRouter)
const View = () => import(/* webpackChunkName: "clinic" */ '@/pages/clinic/view');
// 页面
const DetailPrescriptionCloud = () => import(/* webpackChunkName: "clinic" */ '@/pages/clinic/detail-prescription-cloud/index.vue');
// 子页面
// 西药
const diagnosisWestern = () => import(/* webpackChunkName: "clinic" */ '@/pages/clinic/components/diagnosis-western');
// 中药
const diagnosisChinesePieces = () => import(/* webpackChunkName: "clinic" */ '@/pages/clinic/components/diagnosis-chinese-pieces');
const routes = [
  {
    path: '/',
    name: 'About',
    component: About
  },
  {
    path: '/home2',
    name: 'Home2',
    component: Home2
  },
  {
    path: '/home',
    name: 'Home',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/Home.vue')
  },
  {
    path: '/clinic',
    component: View,
    children: [ {
      name: 'clinic/detail/prescription-nv',
      path: 'prescription-nv',
      component: DetailPrescriptionCloud,
      meta: {
        title: '处方',
        isDetail: true
      },
      // 新的处方nv 配置的中药路由
      children: [
        {
          name: 'clinic/detail/prescription-nv/western',
          path: 'western',
          component: diagnosisWestern,
          meta: {
            title: '西药处方',
            isDetail: true
          }
        },
        {
          name: 'clinic/detail/prescription-nv/chinese-pieces',
          path: 'chinese-pieces',
          component: diagnosisChinesePieces,
          meta: {
            title: '中药饮片',
            isDetail: true
          }
        },
        {
          name: 'clinic/detail/prescription-nv/chinese-granules',
          path: 'chinese-granules',
          component: diagnosisChinesePieces,
          meta: {
            title: '中药颗粒',
            isDetail: true
          }
        }
      ]
    }]
  }
  ,
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
